﻿Imports DTO
Imports System.Data.OleDb
Public Class GiaoVienDAO
    Inherits Connect
    Public Function LayDSGiaoVien() As DataTable
        Dim dt As New DataTable
        Dim cn As New OleDbConnection
        cn = Me.ConnectionData()
        Dim sql As String = "select HoTengiaoVien, TenTat from giaovien"
        Dim da As New OleDbDataAdapter(sql, cn)
        da.Fill(dt)
        cn.Close()
        Return dt
    End Function

    Public Function LayMaGiaoVien(ByVal dto As GiaoVienDTO) As String
        Dim ma As String
        Dim cn As New OleDbConnection
        cn = Me.ConnectionData
        Dim sql As String
        sql = "select MaGiaoVien from giaovien where " & _
        "HoTengiaovien='" & dto.HoTenGiaoVien & "' and " & _
        "Tentat='" & dto.TenTat & "'"
        Dim cmd As New OleDbCommand(sql, cn)
        ma = cmd.ExecuteScalar.ToString
        cn.Close()
        Return ma
    End Function

    Public Function LayDCGiaoVien(ByVal dto As GiaoVienDTO) As String
        Dim dc As String
        Dim cn As New OleDbConnection
        cn = Me.ConnectionData
        Dim sql As String
        sql = "select DiaChi from giaovien where " & _
        "HoTengiaovien='" & dto.HoTenGiaoVien & "' and " & _
        "Tentat='" & dto.TenTat & "'"
        Dim cmd As New OleDbCommand(sql, cn)
        dc = cmd.ExecuteScalar.ToString
        cn.Close()
        Return dc
    End Function

    Public Function LaySDTGiaoVien(ByVal dto As GiaoVienDTO) As String
        Dim sdt As String
        Dim cn As New OleDbConnection
        cn = Me.ConnectionData
        Dim sql As String
        sql = "select DienThoai from giaovien where " & _
        "HoTengiaovien='" & dto.HoTenGiaoVien & "' and " & _
        "Tentat='" & dto.TenTat & "'"
        Dim cmd As New OleDbCommand(sql, cn)
        sdt = cmd.ExecuteScalar.ToString
        cn.Close()
        Return sdt
    End Function
End Class
